<?php

namespace app\admin\controller;

use think\App;
use think\Request;
use think\facade\Session;
use app\admin\services\IndexService;
use app\admin\services\ProblemService;
class Index extends Authent
{
    public function __construct(Request $request = null, App $app = null)
    {
        parent::__construct($request, $app);
        $this->indexService = new IndexService();
        $this->ProblemService = new ProblemService();
        global $authstate;
        if(isset($authstate['status']) && $authstate['status'] !=0 ){
//            echo json_encode($authstate); die;
            echo alert_auth("无访问权限!");
            exit();
        }
    }

    public function getAuth()
    {
        $res = $this->indexService->index();
        return $res;
    }

    /**
     * @return mixed
     * 首页
     */
    public function index()
    {
        $res = $this->indexService->userauth();
        $data = $this->ProblemService->condata();
        $this->assign('data',$data);
        $this->assign('res',$res);
        return $this->fetch();
    }

    /**
     * @return mixed
     * 首页内部页面
     */
    public function main()
    {
        return $this->fetch();
    }


    /**
     * @param 修改管理员密码
     */
    public function edit(){
        $data = $this->indexService->edituser();
        return json($data);
    }

    /**
     * @return mixed
     * 按钮样式页面
     */
    public function button()
    {
        return $this->fetch();
    }

    /**
     * @return mixed
     * 表单
     */
    public function form()
    {
        return $this->fetch();
    }

    /**
     * @return mixed
     * 表格
     */
    public function table()
    {
        return $this->fetch();
    }

    /**
     * @return mixed
     * 表格操作
     */
    public function editform()
    {
        return $this->fetch("edit-form");
    }

    /**
     * @return mixed
     * 导航
     */
    public function nav()
    {
        return $this->fetch();
    }

    /**
     * @return mixed
     * 辅助性元素
     */
    public function auxiliar()
    {
        return $this->fetch();
    }

    /**
     * @return mixed
     * Btable
     */
    public function btable()
    {
        return $this->fetch();
    }

    /**
     * @return mixed
     * navbar组件
     */
    public function navbar()
    {
        return $this->fetch();
    }

    /**
     * @return mixed
     * tab组件
     */
    public function tab()
    {
        return $this->fetch();
    }

    /**
     * @return mixed
     * paging模板
     */
    public function paging()
    {
        return $this->fetch();
    }

    /**
     * @return mixed
     * icheck第三方组件
     */
    public function icheck()
    {
        return $this->fetch();
    }

    /**
     * @return mixed
     * 子窗口中打开选项
     */
    public function cop()
    {
        return $this->fetch();
    }

    /**
     * @return mixed
     * 浏览视频
     */
    public function video()
    {
        return $this->fetch();
    }

}